/**
  * @category	Interface
  * @package		psdup
  * @author		Bilal Cinarli
  * @copyright	2005 - 2011 Bilal Cinarli
  * @license
  * @version
  * @filesource
  * @link		http://bcinarli.com
  * @see
  * @since
 **/
 
 (function($){
    $.fn.blueuiCheckbox = function(options){
        return this.each(function(){
           var $el = $(this);
           var checkedClass = '';
           
           if($el.is(':checked'))
           {
                checkedClass = ' blueui-checked';
           }
           
           if(!$el.parent().is('label')){
                $el.wrap('<label class="blueui-checkbox-label' + checkedClass + '"></label>');
           }
           else{
                $el.parent().addClass('blueui-checkbox-label' + checkedClass);
           }
           
           $el.after('<span class="blueui-input-mask"></span>');
           
           $el.change(function(){
                $(this).parent().toggleClass('blueui-checked');            
           });           
        });
    }
})(jQuery);

 (function($){
    $.fn.blueuiRadio = function(options){
        return this.each(function(){
           var $el = $(this);
           var checkedClass = '';
           
           if($el.is(':checked'))
           {
                checkedClass = ' blueui-checked';
           }
           
           if(!$el.parent().is('label')){
                $el.wrap('<label class="blueui-radio-label' + checkedClass + '"></label>');
           }
           else{
                $el.parent().addClass('blueui-radio-label' + checkedClass);
           }
           
           $el.after('<span class="blueui-input-mask"></span>');
           
           $el.change(function(){
                $(this).parent().siblings().removeClass('blueui-checked');          
                $(this).parent().addClass('blueui-checked');          
           });           
        });
    }
})(jQuery);

 (function($){
    $.fn.blueuiSelect = function(options){
        return this.each(function(){
           var $el = $(this);
           var selectMaskList = '';
           var selectMask = '';
           var selectText = $el.find(':selected').text();
           
           if(!$el.parent().is('label')){
                $el.wrap('<label class="blueui-select-label"></label>');
           }
           else{
                $el.parent().addClass('blueui-select-label');
           }
           
           $el.find('option').each(function(){
                selectMaskList += '<li>' + $(this).text() + '</li>';
           });
           
           $el.after('<span class="blueui-selected-text">' + selectText + '</span><ul>' + selectMaskList + '</ul>');
           
           $el.parent().find('.blueui-selected-text').click(function(){
                $(this).toggleClass('hover');
                $el.parent().find('ul').slideToggle();
           });
           
           $el.parent().find('li').click(function(){
                var text = $(this).text();
                $el.parent().find('.blueui-selected-text').text(text).removeClass('hover');
                $(this).parent().hide();
           });                 
        });
    }
})(jQuery);

 (function($){
    $.fn.blueuiClose = function(options){
        return this.each(function(){
           var $el = $(this);
           $el.click(function(){
				$el.parent().animate({ height: 0, opacity: 0 });
			})
        });
    }
})(jQuery);